package com.sxt.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sxt.system.common.DataGridView;
import com.sxt.system.domain.Notice;
import com.sxt.system.vo.LogInfoVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sxt.system.mapper.LogInfoMapper;
import com.sxt.system.domain.LogInfo;
import com.sxt.system.service.LogInfoService;
@Service
public class LogInfoServiceImpl extends ServiceImpl<LogInfoMapper, LogInfo> implements LogInfoService{

    @Override
    public DataGridView queryAllLogInfo(LogInfoVo logInfoVo) {
        QueryWrapper<LogInfo> qw=new QueryWrapper<>();
        if(null!=logInfoVo){
            qw.like(StringUtils.isNotBlank(logInfoVo.getLoginname()),"loginname",logInfoVo.getLoginname());
            qw.like(StringUtils.isNotBlank(logInfoVo.getLoginip()),"loginip",logInfoVo.getLoginip());

            qw.ge(logInfoVo.getStartTime()!=null,"logintime",logInfoVo.getStartTime());
            qw.le(logInfoVo.getEndTime()!=null,"logintime",logInfoVo.getEndTime());
        }
        qw.orderByDesc("logintime");
        IPage<LogInfo> page=new Page<>(logInfoVo.getPage(),logInfoVo.getLimit());
        this.baseMapper.selectPage(page,qw);
        return new DataGridView(page.getTotal(),page.getRecords());
    }
}
